﻿using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NotificationManager
{
    static class Program
    {
        private static readonly ILog logger = LogManager.GetLogger(typeof(Program));

        public static bool terminate = false;
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            // configure the logger
            log4net.Config.XmlConfigurator.Configure();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            logger.Info("-------------------------------------------------------");
            logger.Info("Starting Notification Processing Thread");
            // start the notification thread
            NotificationProcessingThread thread = new NotificationProcessingThread();
            Thread t = new Thread(new ThreadStart(thread.Run));

            t.Start();

            Application.Run(new NotificationManagerForm());

            logger.Info("Waiting for Notification Processing Thread to Finish");
            // wait for the notification thread to finish
            t.Join();
            logger.Info("Notification Processing Thread Finished.  Terminating Notification Manager.");
            logger.Info("End of Line");
        }
    }
}
